﻿using System.IO;
using OSS.NBEncode.Entities;
using OSS.NBEncode.Transforms;

namespace OSS.NBEncode.Extensions
{
	public static class BObjectExtensions
	{
		public static byte[] ToByteArray(this IBObject obj)
		{
			using (MemoryStream MS = new MemoryStream())
			{
				var transform = new BObjectTransform();
				transform.EncodeObject(obj, MS);
				MS.Position = 0;
				return MS.ToArray();
			}
		}
	}
}
